﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Threading;
using System.Security.Cryptography;

namespace NetworkLibrary
{
    public class EncryptedTransfer
    {
        private RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
        private RSAParameters sendInfo;
        private RSAParameters recvInfo;
        public EncryptedTransfer(RSAParameters sendInfo, RSAParameters recvInfo)
        {
            this.sendInfo = sendInfo;
            this.recvInfo = recvInfo;
        }
        public byte[] Encrypt(byte[] data)
        {
            return rsa.Encrypt(data, true);
        }
        public byte[] Decrypt(byte[] data)
        {
            return rsa.Decrypt(data, true);
        }
        public void prepEncrypt()
        {
            rsa.ImportParameters(sendInfo);
        }
        public void prepDecrypt()
        {
            rsa.ImportParameters(recvInfo);
        }
    }
}
